/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plash.display;

import plash.utils.ColorMapper;
import processing.core.PApplet;

/**
 *
 * @author User
 */
public class GraphicStroke implements IGraphicCommand
{
    private int _thickness;
    private int _rgb;
    private float _alpha;
    
    private Graphics _g;
    private PApplet _painter;    
    private ColorMapper _cmapper;
    
    public GraphicStroke(Graphics g, int lineThickness, int rgb, float alpha)
    {
        _g = g;
        _thickness = lineThickness;
        _painter = g.getPainter();
        _cmapper = new ColorMapper(alpha, rgb);
        _alpha = alpha;
    }
    
    @Override
    public void execute()
    {
        if(_g == null)
        {
            return;
        }
        if(_painter == null)
        {
            _painter = _g.getPainter();
        }
        _painter.strokeWeight(_thickness);
        _painter.stroke(_cmapper.getRed(), _cmapper.getGreen(), _cmapper.getBlue(), _cmapper.getAlpha() * _g.getOwner().getAlpha());
    }    
}
